<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
    <ant-simple-table ref="tableRef" :api="getSysRoleList">

        <!-- 表头操作按钮 -->
        <template v-slot:headerOperators="" >
            <a-button icon="plus" type="primary" @click="$router.push({ name : 'addSysRole' }).then()">新增</a-button>
        </template>

        <!-- 表格列 -->
        <template v-slot:tableColumns="">
            <a-table-column title="角色名称" dataIndex="roleName" :align="'center'"  />
            <a-table-column title="角色描述" dataIndex="roleDescribe" :align="'center'" />
            <a-table-column title="创建时间" dataIndex="createTime" :align="'center'" />
            <a-table-column title="操作">
                <template slot-scope="record">
                    <template>
                        &nbsp;
                        <router-link :to="{ name : 'editAuthorities', params : { roleId : record.id } }">配置权限</router-link>
                        &nbsp;
                        <router-link :to="{ name : 'editSysRole', params : { roleId : record.id } }">修改</router-link>
                        &nbsp;
                    </template>
                    <template>
                        &nbsp;
                        <a href="javascript:void(0);" @click="deleteRole(record['id'])">删除</a>
                        &nbsp;
                    </template>
                </template>
            </a-table-column>
        </template>

        <!-- 抽屉 -->
        <ant-drawer route-name="sysRoleManage" />
    </ant-simple-table>
</template>

<script>
    import AntDrawer from '../../components/drawer/AntDrawer';
    import AntSimpleTable from '../../components/table/AntSimpleTable';
    import { getSysRoleList,deleteSysRole } from '../../apis/upms';
    export default {
        components : { AntDrawer,AntSimpleTable },
        methods : {
            /**
             * 获取角色列表
             */
            getSysRoleList,
            /**
             * 根据Id删除角色
             * @param roleId
             */
            deleteRole : function (roleId) {
                let $this = this;
                deleteSysRole(roleId).then(() => {
                    $this.$message.success("删除成功").then();
                    $this.$router.push({
                        name : 'sysRoleManage',
                        query : { reload : new Date().getTime().toString() }
                    }).then();
                })
            }
        }
    }
</script>
